package com.example.a2018.myapplication;

import android.app.Application;
import android.content.Context;
import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.util.Log;

import com.Exception.ConnectException;
import com.tutk.IOTC.AVAPIs;
import com.tutk.IOTC.IOTCAPIs;

import java.io.IOException;

/**
 * Created by 李文旭 on 2018/9/4.
 */

public class MainApplication extends Application {
    public static int sessionId=-1;
    public  static Context context;
    @Override
    public void onCreate()
    {
        super.onCreate();
        //启动线程执行下载任务
        this.context=getApplicationContext();
        int ret = IOTCAPIs.IOTC_Initialize2(0);
        sessionId = IOTCAPIs.IOTC_Connect_ByUID_Parallel("GV4GRAS1S2XJY3F1111A", IOTCAPIs.IOTC_Get_SessionID());//连接获取sessionId
        AVAPIs.avInitialize(3);
        //IOTCAPIs.IOTC_Session_Close(sessionId);//关闭
        //IOTCAPIs.IOTC_DeInitialize();//释放资源
        try {
            check(ret);
            check(sessionId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Log.d("para", ret + " " + sessionId + "  " );

    }
    public void check(int ready) throws Exception {
        if(ready!=0)
        {
            throw new ConnectException("连接服务器失败",ready);
        }
    }
}

